home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 41.zip
/
BS1 part 41
/
Lattice C v5.02 d4.adf
/
examples
/
debugger
/
showcli.cpr
< prev
next >
Wrap
Text File
|
1988-11-07
|
4KB
|
144 lines
/*
Usage: ShowCLI [ <command> | 0xnnnnnn | n]
Version 1.00 02-Nov-88
Dumps the CLI structure for a given command, process address
or task address
*/
parse arg name '0x' tsk .
NULL = "00000000"x
if (name = '?') then
do
do i = 2 to 6
'd "'||strip(sourceline(i),'T',"0a"x) '"'
end
exit(0)
end
else if (name ~= '') then
do
if datatype(name, 'W') then
do
clinum = name
name = 'Process' name
end
else
cliname = name
end
else if (tsk ~= '') then
do
name = right(tsk,8,'0')
taskbase = x2c(name)
name = '0x'||name
end
else
do
options results
'd a7 %08x'
sp = left(result,8)
'tasks'
tasklist = result
options
/* Now figure out where the stack pointer should be */
sp = c2x(offset(x2c(sp),-118))
place = index(tasklist,sp)
if (place = 0) then place = 87
name = substr(tasklist, place-33, 8)
taskbase = x2c(name)
name = '0x'||name
end
/* Show all CLI tasks */
dosbase = findlib("dos.library")
rootnode = import(offset(dosbase,34),4)
tasktable = d2c(c2d(import(rootnode,4))*4,4)
taskcount = c2d(import(tasktable,4))
do tasknum = 1 to taskcount
proc = import(offset(tasktable,tasknum*4),4)
if (proc ~= NULL) then
do
proc = offset(proc,-92)
cli = d2c(c2d(import(offset(proc,172),4))*4,4)
command = 'No command loaded'
module = ''
if (cli ~= NULL) then
do
cmdname = d2c(c2d(import(offset(cli,16),4))*4,4)
cmdlen = c2d(import(cmdname, 1))
module = import(offset(cmdname,1), cmdlen)
if cmdlen ~= 0 then
command = 'Loaded as command:' module "0x"||c2x(proc)
end
if (proc = taskbase | module = cliname | tasknum = clinum) then
do
'd "Process' tasknum||':' command '"'
/* Now dump the CLI Structure */
pbstr = d2c(c2d(import(offset(cli,24),4))*4,4)
prompt = import(offset(pbstr,1),c2d(import(pbstr,1)))
'd "Prompt : \"' || prompt || '\""'
cbstr = d2c(c2d(import(offset(cli,4),4))*4,4)
curdir = import(offset(cbstr,1),c2d(import(cbstr,1)))
'd "Currentdir : \"' || curdir || '\""'
ebstr = d2c(c2d(import(offset(cli,36),4))*4,4)
execfile = import(offset(ebstr,1),c2d(import(ebstr,1)))
'd "ExecuteFile: \"' || execfile || '\""'
rslt2 = right(c2d(import(cli,4)),8)
retc = right(c2d(import(offset(cli,12),4)),8)
stack = c2d(import(offset(cli,52),4))*4
'd "Result2: ' rslt2 ' ReturnCode: ' retc ' Stack:' stack '"'
faillev = right(c2d(import(offset(cli,20),4)),8)
interactive = "NONInteractive"
if (import(offset(cli,40),4) ~= NULL) then interactive = "Interactive "
type = "Foreground"
if (import(offset(cli,44),4) ~= NULL) then type = "Background"
'd "FailLevel: ' faillev ' ' interactive ' ' type '"'
stdin = '$'||c2x(d2c(c2d(import(offset(cli,28),4))*4,4))
curin = '$'||c2x(d2c(c2d(import(offset(cli,32),4))*4,4))
redir = ''
if (stdin ~= curin) then redir = ' <Redirected>'
'd "StdInput: ' stdin ' CurrentInput: ' curin redir'"'
stdout = '$'||c2x(d2c(c2d(import(offset(cli,48),4))*4,4))
curout = '$'||c2x(d2c(c2d(import(offset(cli,56),4))*4,4))
redir = ''
if (stdin ~= curin) then redir = ' <Redirected>'
'd "StdOutput:' stdout ' CurrentOutput:' curout redir'"'
seglist = '$'||c2x(d2c(c2d(import(offset(cli,60),4))*4,4))
path = '$'||c2x(d2c(c2d(import(offset(cli,8),4))*4,4))
'd "Seglist: ' seglist ' Path: ' path '"'
exit(0)
end
end
end
'd "Unable to find' name '"'
exit(0)
/* Find a given library in the system */
findlib:
parse arg tofind
execbase = import("00000004"x,4)
liboff = 378
nodebase = import(offset(execbase, liboff), 4)
do while(import(nodebase,4) ~= NULL)
if import(import(offset(nodebase,10),4)) = tofind then return nodebase
nodebase = import(nodebase,4)
end
'd "Could not find' tofind||'"'
exit(0)